package com.java01.misc.config;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Properties;
import java.util.Map.Entry;

public class PropertiesConfig {

	public static void main(String[] args) {
		
		File configFile = new File("c:\\my.conf");
		
		Properties properties = new Properties();
		properties.put("name", "atoo");
		properties.put("gender", "male");
		properties.put("phone", "555-1234");
		
		try {
			properties.store(new FileOutputStream(configFile), "My Config");
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		properties.clear();
		
		try {
			properties.load(new FileInputStream(configFile));
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		for(Entry<Object, Object> entry:properties.entrySet()){
			System.out.println("key="+entry.getKey()+" value="+entry.getValue());
		}
	}
}
